<div id="proposalsPage">
    <div class="post">
        <h2 class="title">Proposals</h2>
        <div class="entry">
            <div id="prop_result" style="display: none">
            </div>
            <script>
                $(function() {
                    $( "#proposal_datepicker" ).datepicker({ dateFormat: 'yy-mm-dd' });
                });
                $(function() {
                    $( "#proposal_datepicker2" ).datepicker({ dateFormat: 'yy-mm-dd' });
                });
                $(function() {
                    $( "#proposal_datepicker3" ).datepicker({ dateFormat: 'yy-mm-dd' });
                });
            </script>
            <input type="button" value="Add new" onclick="show('#new_prop')"/>

            <?php
          //  if ($this->session->userdata("admin")) {
            ?>
                <input type="button" value="Search" onclick="show('#searchProposals')"/>    
                <input type="button" value="Clear Search" onclick="clearSearch()"/>
            <?php
            //}
            ?>

            <div id="proposal_result" class="info">
                <?= $message ?>
            </div>
            <script type="text/javascript">
                function searchProposals(){
                    field=document.getElementById("searchProposalsForm").field.value;
                    search=document.getElementById("searchProposalsForm").search.value;
                    $("#proposalsPage").load("<?= base_url(); ?>index.php?/admin_mis/proposals/"+field+"/"+search);
                }
                function clearSearch(){
                    $("#proposalsPage").load("<?= base_url(); ?>index.php?/admin_mis/proposals/");
                }
            </script>

            <!--a href="" id="hide3" >Hide</a> <a href="" id="show3" >Show</a-->
            <div id="new_prop" style="display: none;margin-bottom: 10px;">
                <?php $data['id'] = "prop_form" ?>
                <?= form_open_multipart('mis/saveProposal', $data); ?>
                <table>
                    <tr class="darker"><td class="half">Title</td><td><input type="text" class="wide" name="title" value="<?php echo set_value('title'); ?>" /></td> </tr>
                    <tr class="lighter"><td class="half">Date advertised</td><td><input type="text" class="wide" name="date_advert" value="<?php echo set_value('date_advert'); ?>" id="proposal_datepicker"/></td> </tr>
                    <tr class="darker"><td class="half">Source of information</td><td><input type="text" class="wide" name="source" value="<?php echo set_value('source'); ?>" /></td> </tr>
                    <tr class="lighter"><td class="half">Contact</td><td><input type="text" class="wide" name="contact" value="<?php echo set_value('contact'); ?>" /></td> </tr>
                    <tr class="darker"><td class="half">Deadline</td><td><input type="text" class="wide" name="deadline_date" value="<?php echo set_value('deadline_date'); ?>" id="proposal_datepicker2"/></td> </tr>
                    <tr class="lighter"><td class="half">Date sent</td><td><input type="text" class="wide" name="date_sent" value="<?php echo set_value('date_sent'); ?>" id="proposal_datepicker3"/></td> </tr>
                    <tr class="darker"><td class="half">Sent to</td><td><input type="text" class="wide" name="sent_to" value="<?php echo set_value('sent_to'); ?>" /></td> </tr>
                    <tr class="lighter"><td class="half">Value</td><td><input type="text" class="wide" name="value" value="<?php echo set_value('value'); ?>" /></td> </tr>
                    <tr class="darker"><td>Upload proposal/narrative</td><td><input type="file" class="wide"  name="userfile" /></td> </tr>
                    <tr><td colspan="2" style="text-align: right">
                            <input type="submit" value="Submit" />
                            <input type="button" value="Cancel" onclick="hide('#new_prop')"/>
                        </td></tr>
                </table>
                </form>
            </div>



            <div id="searchProposals" style="display: none;margin-bottom: 10px;">
                <form id="searchProposalsForm">
                    <table>
                        <tr class="darker"><td class="half">Select search criteria</td>
                            <td><select name="field">
                                    <option value='all'>All</option>
                                    <option value='title'>Title</option>
                                    <option value='source'>Source of information</option>
                                    <option value='contact'>Contact</option>
                                    <option value='sent_to' >Sent to</option>
                                    <option value='added_by' >Added by</option>
                                </select></td>
                            <td><input type="text" name="search" class="wide"  value="<?php echo set_value('added_by'); ?>" /></td>
                        </tr>

                        <tr><td colspan="3" style="text-align: right">
                                <input type="button" value="Submit" onclick="searchProposals()" />
                                <input type="button" value="Cancel" onclick="hide('#searchProposals')"/>
                            </td></tr>

                    </table>
                </form>
            </div>
        </div>
        <div id="all_props">
            <?= $tablet ?>
            <?= $pagina ?>
        </div>

    </div>
</div>
</div>